interface routesType {
  name: string
  path: string
  meta?: {
    tabbar?: boolean
    svgPath?: string
    tabberPath?: string
  }
  redirect?: string
  children?: any
  component?: () => {}
}

// 动态导入 SVG 文件
const svgIcons = import.meta.glob('@/assets/icon/*.svg', { eager: true })

export const tabber: routesType[] = [
  {
    name: '首页',
    path: '/',
    meta: {
      tabbar: true,
      svgPath: 'icon-Homehomepagemenu',
      tabberPath: '/',
    },
    component: () => import('@/views/Home.vue'),
  },
  {
    name: '友链',
    path: '/space/friend',
    meta: {
      tabbar: true,
      svgPath: 'icon-youqinglianjie',
      tabberPath: '/space/friend',
    },
    component: () => import('@/views/firend/index.vue'),
  },
  {
    name: '文章',
    path: '/article/category',
    meta: {
      tabbar: true,
      svgPath: 'icon-article',
      tabberPath: '/article/category',
    },
    redirect: '/article/category',
    children: [
      {
        name: '文章分类',
        path: '/article/category',
        component: () => import('@/views/article/category/index.vue'),
      },
      {
        name: '全部文章',
        path: '/allArticle',
        component: () => import('@/views/article/allArticle/index.vue'),
      },
    ],
  },
]

export const asyncRoutes: routesType[] = [
  //   {
  //     name: '发布文章',
  //     path: '/pushArticle',
  //     meta: {
  //       tabbar: true,
  //     },
  //     component: () => import('@/views/article/writeArticle/index.vue'),
  //   },
]
// 通用路由
export const asyncCommon: routesType[] = [
  {
    name: '文章详情',
    path: '/articleDetail',
    component: () => import('@/views/article/articleDetails/index.vue'),
  },
]

export const routes: routesType[] = [
  ...asyncCommon,
  ...asyncRoutes,
  ...tabber,
  {
    name: '登录',
    path: '/login',
    meta: {
      tabbar: true,
    },
    component: () => import('@/views/login/login.vue'),
  },
  {
    name: '注册',
    path: '/register',
    meta: {
      tabbar: true,
    },
    component: () => import('@/views/login/register.vue'),
  },
  {
    name: '忘记密码',
    path: '/forget',
    meta: {
      tabbar: true,
    },
    component: () => import('@/views/login/forgetPwd.vue'),
  },
]
